package com.ucomm.talent.adapter;

import java.util.ArrayList;

import com.ucomm.talent.AppConfig;
import com.ucomm.talent.R;
import com.ucomm.talent.model.ResumeInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ResumeInfoListAdapter extends BaseAdapter{
	
	private LayoutInflater layoutInflater;
	private ArrayList<ResumeInfo> mData;

	public ResumeInfoListAdapter(Context context,ArrayList<ResumeInfo> mData) {
		this.layoutInflater = LayoutInflater.from(context);
		this.mData = mData;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mData.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
	        if (convertView == null) {

	            holder=new ViewHolder();

	            convertView = layoutInflater.inflate(R.layout.resume_item_layout, null);
	            holder.resumeId = (TextView) convertView.findViewById(R.id.resume_id);
	            holder.resumeName = (TextView)convertView.findViewById(R.id.resumeName);
	            holder.jobType = (TextView)convertView.findViewById(R.id.jobType);
	            holder.salary = (TextView) convertView.findViewById(R.id.salary);
	            holder.type = (TextView) convertView.findViewById(R.id.type);
	            convertView.setTag(holder);

	        }else {
	            holder = (ViewHolder)convertView.getTag();
	        }
	        ResumeInfo info = mData.get(position);
	        String jobType = null;
	        String salary = null;
	        String type = null;
	        if(AppConfig.userMap.size()!=0 && AppConfig.jobMap.size()!=0){
	        	jobType = AppConfig.jobMap.get(info.getJobType());
	        	salary = AppConfig.userMap.get(info.getSalary()+"");
	        	type = AppConfig.userMap.get(info.getType());
	        }
	        holder.resumeId.setText(info.getResumeId()+"");
	        holder.resumeName.setText(info.getResumeName());
	        holder.jobType.setText(jobType);
	        holder.salary.setText(salary);
	        holder.type.setText(type);
	        return convertView;
	}
	final class ViewHolder{
		public TextView resumeId;
		public TextView resumeName;
		public TextView jobType;
		public TextView salary;
		public TextView type;
	}
	public ArrayList<ResumeInfo> getmData() {
		// TODO Auto-generated method stub
		return mData;
	}
 } 